const { resolve } = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const AddAssetHtmlWebpackPlugin = require('add-asset-html-webpack-plugin')

module.exports = {
    mode: 'production',
    entry: './src/index.js',
    output: {
        clean: true,
        filename: 'js/[name].js',
        path: resolve(__dirname, 'dist'),
        environment: {
            arrowFunction: false,
            const: false
        }
    },
    plugins: [
        new webpack.DllReferencePlugin({
            manifest: resolve(__dirname, './dll/manifest.json')
        }),
        new HtmlWebpackPlugin({
            template: resolve(__dirname, './src/index.html'),
            minify: false,
            hash: true,
            inject: 'body'
        }),
        new AddAssetHtmlWebpackPlugin({
            filepath: resolve(__dirname, './dll/React.js'),
            outputPath: './lib/',
            publicPath: './lib/'
        }),
        new AddAssetHtmlWebpackPlugin({
            filepath: resolve(__dirname, './dll/ReactDOM.js'),
            outputPath: './lib/',
            publicPath: './lib/'
        })
    ]
}